'use strict';

angular.module('app')
    .controller('adminController', ['$scope','$rootScope','$http','$state',
        function ($scope,$rootScope,$http,$state) {
            $scope.$on('$viewContentLoaded', function () {
                layui.use(['element'], function () {
                    var element = layui.element;
                });
            });
            $scope.defaultAvatar = $rootScope.defaultAvatar = 'res/img/avatar.png';
            $scope.logout = function () {
                console.info('logout');
                return $.ajax({
                    type: 'POST',
                    url: '/logout'
                }).then(function (result) {
                    if (result.httpCode == 200) {//注销成功
                        deleteUserInfo();
                        $state.go('login');
                    }
                });

                function deleteUserInfo() {
                    $.cookie('_ihome_uid', null);
                }
            };
        }]);